package com.xtyhz.config.mybatisPlus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

/**
 * @author 高玉
 */
@Configuration
public class AutoMybatisPlus implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        // 设置创建时间
        this.strictInsertFill(metaObject, "createdTime", Date.class, new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 设置更新时间
        this.strictInsertFill(metaObject, "updatedTime", Date.class, new Date());
    }
}